package com.cloudcross.ssp.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.cloudcross.ssp.base.service.IGenericService;
import com.cloudcross.ssp.base.web.result.AjaxResult;
import com.cloudcross.ssp.common.utils.Pager;
import com.cloudcross.ssp.model.Account;
import com.cloudcross.ssp.model.AdGroup;
import com.cloudcross.ssp.model.AdGroupNum;
import com.cloudcross.ssp.model.AdsVoEntity;
import com.cloudcross.ssp.model.CategoryEntity;
import com.cloudcross.util.SqlServer;

/**
 * 策略接口服务定义
 *
 * @author wuqiang.du
 * @version 1.0.1 $2018-1-17
 */
public interface IAdGroupService extends IGenericService<AdGroup> {
    //根据订单id得到它有几个投放
    List<AdGroup> findByOrderId(Long orderId);

    /**
     * 新增投放信息
     *
     * @param adGroup
     * @param targetParamsMap
     * @return
     */
    boolean save(AdGroup adGroup, Map<String, Object> targetParamsMap, HttpServletRequest request, Account account);

    /**
     * 编辑投放信息
     *
     * @param adGroup
     * @param targetParamsMap
     * @return
     */
    boolean edit(AdGroup adGroup, Map<String, Object> targetParamsMap, HttpServletRequest request, Account account);

    List<AdGroup> findByParams(Map<String, Object> paramMap);

    List<Long> findAllAdGroudByAdvertiserId(Long advertiserId);

    boolean updateSupdatedByAdvertiserId(List<Long> advertiserIdList, Date date);

    boolean updateSupdatedByOrderId(List<Long> orderIdList, Date date);

    boolean updateStatusByAdvertiserId(List<Long> AdvertiseIdList, int status);

    boolean updateStatusByOrderId(List<Long> AdvertiseIdList, int status);

    boolean updateStatusAll(List<Long> adGroupIdList, int status);

    int countByParamsBack(Map<String, Object> paramMap);

    List<AdGroup> findByParamsBack(Map<String, Object> paramMap, Pager pager);

    Map findAreasBack(Long adGroupId);

    Integer queryAdGroupCountByCondition(Map<String, Object> paramMap);

    List<AdGroup> queryAdGroupByCondition(Map<String, Object> paramMap, Pager pager);

    boolean updateAdgroupZone(AdGroup adGroup, Map<String, Object> condition);

    void saveAllOperator(AdGroup adGroup, Map<String, Object> condition, HttpServletRequest request, Account account);

    boolean saveUpdateAdgroup(AdGroup adGroup, Map<String, Object> paramMap, HttpServletRequest request,
                              Account account);

    String queryAdgroupNameById(Long id);

    boolean updateAdgroupDateByCondition(List<Long> idList, Date start, Date end);

    boolean cpoyAdGroup(AdGroup adgroup);

    AjaxResult copyAdgroup2Order(List<Long> orderList, List<Long> adgroupList, int type);

    AdGroup queryAdGroupByOrderId(Long orderId);

    List<AdGroupNum> getAdgroupNumById(Long adGroupId);

    boolean deleteAdgroupNumById(Long adGroupId);

    void insertAdGroupNumList(List<AdGroupNum> adGroupNumList);

    void updateHtml(AdGroup t);

    /**
     * 获取分类信息
     *
     * @param deviceType
     * @param sqlServer
     * @return
     */
    List<CategoryEntity> getCategoryList(String deviceType, SqlServer sqlServer);

    /**
     * app获取二级分类信息
     *
     * @param categoryId
     * @param sqlServer
     * @return
     */
    List<CategoryEntity> getSubCategoryList(Integer categoryId, SqlServer sqlServer);

    /**
     * 获取ctr明细
     *
     * @param adid
     * @param date
     * @param sqlServer
     * @return
     */
    Double queryCtrByAdid(Integer adid, String date, SqlServer sqlServer);

    /**
     * 获取ctr明细
     *
     * @param dailyMaxImpression
     * @param dailyMaxClick
     * @param adgroupId
     * @param sqlServer
     * @param deviceType
     * @param condition
     */
    List<AdsVoEntity> recommendAdsList(Map<String, Object> condition, Long adgroupId, Long dailyMaxClick, Long dailyMaxImpression, SqlServer sqlServer, String deviceType);

    /**
     * 根据排期下线策略
     *
     * @return
     */
    void offLineAdgroup();

    /**
     * 更新是否编辑过
     *
     * @return
     */
    void updateIsEdit(AdGroup t);
}